<?php
/**
 * Created by PhpStorm.
 * User: dumbledore
 * Date: 2018/3/27
 * Time: 下午3:37
 */
?>
<!DOCTYPE html>
<html>
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
    <![endif]-->

    <meta charset="utf-8">
    <title>首页-文具1号</title>
    <meta name="description"
          content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
    <meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
    <meta name="copyright" content="上海易推信息科技有限公司"/>
    <meta name="renderer" content="webkit">
    <base href="<?php echo base_url(); ?>"/>
    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="stylesheet" type="text/css" href="public/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/cost-center.css"/>

    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
    <![endif]-->
</head>
<style>
    .closes{position: absolute;margin-left:420px;margin-top: 10px;z-index: 2;color: #ffffff
    }
</style>
<body>
<div class="bg">
    <!--common - head -->
    <?php $this->load->view('common/header.php'); ?>

    <!--common - head end-->

    <div class="container mt20 bg-padding-inside">
        <div class="cost-center-container">
            <div class="pop pop-new-cost-center bg-padding-inside">
                <a href="<?php echo base_url()?>cost_center/cost_center_index" class="closes">返回</a>
                <p class="top-tit">
                    <span class="bg-logo_popup"></span>
                </p>
                <div class="cont adjustment-budget-cont">
                    <p class="tit">成本中心</p>
                    <?php if (isset($cost_center)): ?>
                        <input type="text" id="name" class="create-cost-center-input"
                               maxlength="10"      p="<?php echo $cost_center['id'] ?>" value="<?php echo $cost_center['name'] ?>"
                               placeholder="请输入成本中心名称">
                    <?php endif; ?>
                    <p class="intro">*可输入部门或分公司名称，达到成本的有效管控</p>
                    <button class="adjustment-budget-submit" onclick="update()">保存修改</button>
                </div>
            </div>
            <!--编辑成本中心-->
        </div>
    </div>

    <?php $this->load->view('common/bottom.php'); ?>
</div>
<script type="text/javascript" src="public/js/jquery.min.js"></script>
<script type="text/javascript" src="public/js/index.js"></script>
<script type="text/javascript" src="public/js/owl.carousel.min.js"></script>

<script>
    function update() {
        if (!$("#name").val()) {
            layer.msg('请输入成本中心名称');
        } else {
            $.ajax({
                type: "POST",
                url: "cost_center/edit_cost_center_index",
                data: {'name': $("#name").val(), 'id': $("#name").attr('p')},
                dataType: "json",
                async: true,
                success: function (data) {
                    console.log(data);
                    if (data.code == 0) {
                        layer.msg('保存成功');
                        setTimeout(function () {
                            window.location.href = "<?php echo base_url('cost_center/cost_center_index');?>";
                        }, 2000);
                    } else {
                        layer.alert(data.msg)
                    }
                }
            });
        }
    }

</script>
</body>
</html>
